require.config(window.jshead);
require(['jquery', 'pages', "layer",'navigator','common'], function ($, pg,layer) {
    var userId=decodeURI(window.location.href).split('?')[1];
    $("#assessment_btn").val(20);
    $(".question input").bind('click',function(){
        var ques1 =$("input[name='question1']:checked").val()*1;
        var ques2 =$("input[name='question2']:checked").val()*1;
        var ques3 =$("input[name='question3']:checked").val()*1;
        var ques4 =$("input[name='question4']:checked").val()*1;
        var ques5 =$("input[name='question5']:checked").val()*1;
        var ques6 =$("input[name='question6']:checked").val()*1;
        var ques7 =$("input[name='question7']:checked").val()*1;
        var ques8 =$("input[name='question8']:checked").val()*1;
        var ques9 =$("input[name='question9']:checked").val()*1;
        var ques10 =$("input[name='question10']:checked").val()*1;
        var quesAll = ques1+ques2+ques3+ques4+ques5+ques6+ques7+ques8+ques9+ques10;
        $("#assessment_btn").val(quesAll);
    });
    $(".assessment_btn").bind("click",function(){
        if($("#assessment_btn").val()>=20 && $("#assessment_btn").val()<40){
            $(".assessment_alert").show();
            $(".assessment_alert .type").html("保守型");
            $(".assessment_alert .text").html("希望本金安全，能接受较小的价格波动；愿意尝试得到大于定期存款的回报并承担较小风险，希望投资本金不因通货膨胀而贬值。");
        }else if($("#assessment_btn").val()>=40 && $("#assessment_btn").val()<60){
            $(".assessment_alert").show();
            $(".assessment_alert .type").html("稳健性");
            $(".assessment_alert .text").html("能接受适中的价格波动；能承受较高的投资风险；偏好投资兼具成长性及收益性的产品。");
        }else if($("#assessment_btn").val()>=60 && $("#assessment_btn").val()<100){
            $(".assessment_alert").show();
            $(".assessment_alert .type").html("积极型");
            $(".assessment_alert .text").html("资产市值波动比较大，可能会低于原始投资本金；能承担全部收益包括本金可能损失的风险，预期收益率较高；偏好投资高成长的产品或投机性产品，希望投资较快的增长，尽可能获得最高回报。");
        }
        $.ajax({
            type: "POST",
            url: "/user/info/modifyInfo",
            data: {
                userRiskType:$("#assessment_btn").val(),
                id:userId
            },
            dataType: "json",
            success: function (data) {
                console.log(data);

            }
        });
    })
    $("#make").bind("click", function () {
        if($.cookie('the_cookie') && $.cookie('the_cookie')!='null'){
            window.location.href=$.cookie('the_cookie');
            $.cookie('the_cookie',null);
        }else{
            window.location.href="/item/investmentList?0?1";
        }

    })
    $("#again").bind("click",function(){
        $(".assessment_alert").hide();
        $("#assessment_btn").val(20);
        $('input:radio[name=question1]')[0].checked = true;
        $('input:radio[name=question2]')[0].checked = true;
        $('input:radio[name=question3]')[0].checked = true;
        $('input:radio[name=question4]')[0].checked = true;
        $('input:radio[name=question5]')[0].checked = true;
        $('input:radio[name=question6]')[0].checked = true;
        $('input:radio[name=question7]')[0].checked = true;
        $('input:radio[name=question8]')[0].checked = true;
        $('input:radio[name=question9]')[0].checked = true;
        $('input:radio[name=question10]')[0].checked = true;
    })
    if ((navigator.userAgent.indexOf('MSIE') >= 0)
        && (navigator.userAgent.indexOf('Opera') < 0)){
    }else{
        $("input[type='radio']").addClass("assessInput");
        $("input[type='radio']:checked").addClass("assessInput");
    }
})